<?php require ('setcookie.html'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html lang="de">
<head>
    <title>Lingomoto - Freischaltung Newsletter - Sprachen lernen</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="description" content="Lingomoto - Freischaltung Newsletter - Sprachen lernen" />
    <meta name="language" content="de" />
    <link href="style.css" type="text/css" rel="stylesheet" />
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
</head>

<body >

<?php
$_SESSION['logini'] = isset($_SESSION['logini']) ? $_SESSION['logini'] : false;
// read configuration
require ('konfiguration.html');
// read header
$link = "nl-frei.html";
$langen = 'nl-free.html';
$langes = 'nl-libre.html';
$langru = 'nl-free.html';
require ('kopf.html');
// <!-- horizontal column -->
echo '<div>';
require ('horizontal.html');
echo '</div>';
// <!-- Left Column -->
echo '<div id="left_col">';
require ('vertikal.html');
echo '</div>';
?>

<!-- Content -->

<div id="content">
<div id="block5">
<?php
$id = isset($_GET['id']) ? $_GET['id'] : "";
$email = isset($_GET['mail']) ? $_GET['mail'] : "";

$sql = "SELECT * FROM customerdata where email ='". $email . "' and ncontrolno =". $id ." ";

// DB Query
$db_sel1 = mysql_query( $sql );
if ( ! $db_sel1 )
    { die('Error query: ' . mysql_error()); }
else
    { $num_rows = mysql_num_rows($db_sel1);
    if ( $num_rows <> 0 ) { update(); }
    else {
        echo "<div class='message'>Email ";
        echo $email;
        echo " noch nicht registriert. Bitte Newsletter neu bestellen oder registrieren!</div>";
        }
    }


// ----------------------- Functions --------------------------------------------------------------------------------------------

function update () {

    global $email,$id;

    $sql1  = "update customerdata set newsletter = 1 where email ='". $email . "' ";
    $sql1 .= "and ncontrolno =". $id . " ";

    // DB Query
    $db_upd = mysql_query( $sql1 );
    if ( ! $db_upd )
        { die('Error query: ' . mysql_error()); }
    else
        {
            echo "<h2>Der Newsletter wurde freigeschaltet</h2>"; 
        }
}

?>
</div>
</div>

<?php
require ('fuss.html');
?>

</body>
</html>